﻿using IdentityServer4.Extensions;
using IdentityServer4.Models;
using IdentityServer4.Services;
using System.Security.Claims;

namespace IdentityServer
{
    public class ProfileService : IProfileService
    {
       

        public Task GetProfileDataAsync(ProfileDataRequestContext context)
        {
            if (context.RequestedClaimTypes.Any())
            {

                context.AddRequestedClaims(new List<Claim> { new Claim("admin", context.Subject.GetSubjectId()), });
            }
	
            return Task.FromResult(0);
        }

        /// <summary>
        /// 验证用户是否有效 例如：token创建或者验证
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public Task IsActiveAsync(IsActiveContext context)
        {
            //var user = _userManager.GetUserAsync(context.Subject).Result;
            context.IsActive = true;
            return Task.FromResult(0);
        }
    }
}
